package com.ruoyi.project.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.project.warehouse.domain.RyInventoryCurrentStockVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouse.domain.RyLendingReturnRecord;
import com.ruoyi.project.warehouse.service.IRyLendingReturnRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 借出归还记录Controller
 * 
 * @author 萧雪
 * @date 2022-09-06
 */
@RestController
@RequestMapping("/warehouse/RyLendingReturnRecord")
public class RyLendingReturnRecordController extends BaseController
{
    @Autowired
    private IRyLendingReturnRecordService ryLendingReturnRecordService;

    /**
     * 查询借出归还记录列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyLendingReturnRecord ryLendingReturnRecord)
    {
        startPage();
        List<RyLendingReturnRecord> list = ryLendingReturnRecordService.selectRyLendingReturnRecordList(ryLendingReturnRecord);
        return getDataTable(list);
    }

    /**
     * 导出借出归还记录列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:export')")
    @Log(title = "借出归还记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyLendingReturnRecord ryLendingReturnRecord)
    {
        List<RyLendingReturnRecord> list = ryLendingReturnRecordService.selectRyLendingReturnRecordList(ryLendingReturnRecord);
        ExcelUtil<RyLendingReturnRecord> util = new ExcelUtil<RyLendingReturnRecord>(RyLendingReturnRecord.class);
        util.exportExcel(response, list, "借出归还记录数据");
    }

    /**
     * 获取借出归还记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ryLendingReturnRecordService.selectRyLendingReturnRecordById(id));
    }

    /**
     * 新增借出归还记录
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:add')")
    @Log(title = "借出归还记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyLendingReturnRecord ryLendingReturnRecord)
    {
        return toAjax(ryLendingReturnRecordService.insertRyLendingReturnRecord(ryLendingReturnRecord));
    }

    /**
     * 修改借出归还记录
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:edit')")
    @Log(title = "借出归还记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyLendingReturnRecord ryLendingReturnRecord)
    {
        return toAjax(ryLendingReturnRecordService.updateRyLendingReturnRecord(ryLendingReturnRecord));
    }

    /**
     * 删除借出归还记录
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyLendingReturnRecord:remove')")
    @Log(title = "借出归还记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryLendingReturnRecordService.deleteRyLendingReturnRecordByIds(ids));
    }
}
